package userService

import (
	userDto "news_for_deepseek_interface/dto/admin/system/user"
	"news_for_deepseek_interface/model"
	adminModel "news_for_deepseek_interface/model/admin"
	adminService "news_for_deepseek_interface/service/admin"
)

func UpdateStatus(params userDto.UpdateStatusRequest) error {
	db := model.GetInstance().GetDB()

	// 更新状态
	if err := db.Model(&adminModel.AdminStruct{}).
		Where("id = ?", params.Id).
		Update("status", params.Status).Error; err != nil {
		return err
	}

	// 更新token
	_, _, _, err := adminService.UpdateAccessToken(params.Id)
	if err != nil {
		return err
	}

	return nil
}
